/*
 * @Author: cmd
 * @we_chat: cmd_develop
 * @qq群: 790373986
 * @LastEditors: cmd
 * @Description: 
 * @Date: 2019-03-20 22:45:09
 * @LastEditTime: 2019-03-20 22:49:00
 */

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    @property(cc.Label)
    label: cc.Label = null;

    @property
    text: string = 'hello';

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    start () {

    }

    /**
     * 
     * @param dir_scene 准备跳去那个场景
     * @param pre_scene 预加载那个场景
     */
    scene_change(dir_scene,pre_scene?:any){
        var asd = function (completedCount,totalCount,item) {
            console.log("completedCount:" + completedCount + ",totalCount:" + totalCount );
            var per = completedCount / totalCount;            
            this.node.getChildByName('progress_bar').getComponent(cc.ProgressBar).progress = per;            
        }.bind(this);
        
        cc.director.preloadScene(pre_scene, asd, function(){
            console.log('加载完成');            
            this.node.getChildByName("progress_bar").active = false; 
            cc.find("Canvas").runAction(cc.sequence(cc.fadeOut(1.0), cc.callFunc(function(){
                    cc.director.loadScene(dir_scene);
            })));            
        });
    }

    // update (dt) {}
}
